import { flowRequest, apwsfRequest, apscRequest, aomRequest, iamRequest } from "@/utils/request";
import request from '@apulis/request';

export const listAPI = '/task';
export async function getTasks(data: object) {
  return await flowRequest(`/task`, {
    method: 'GET',
    params: data,
  });
}

export async function deleteTask(taskId: string) {
  return await flowRequest(`/task/${taskId}`, {
    method: 'DELETE',
  });
}

export async function updateTask(taskId: string, data: object) {
  return await flowRequest(`/task/${taskId}`, {
    method: 'PATCH',
    data: data,
  });
}

export async function getTaskDetail(taskId: string) {
  return await flowRequest(`/task/${taskId}`, {
    method: 'GET',
  });
}

export async function createTask(data: object) {
  return await flowRequest(`/task`, {
    method: 'POST',
    data: data,
  });
}

//获取模型部分

export async function getModels(data: object) {
  return await apwsfRequest('/studioModels', {
    method: 'GET',
    params: data,
  });
}

export async function getModelsInference(data: object) {
  return await apwsfRequest('/StudioGetManifest', {
    method: 'GET',
    params: data,
  });
}

export async function getModelVersions(modelId: string,data: object) {
  return await apwsfRequest(`/studioModelVersionsByModel/${modelId}`, {
    method: 'GET',
    params:data
  });
}


export async function getDeviceList(data: object) {
  return await apscRequest('/resource-quotas', {
    method: 'GET',
    params: data,
  });
}

//获取推理的详细init数据,逻辑比较复杂

export async function getPredictInfo(taskId: string) {
  return await flowRequest(`/task/predict_info/${taskId}`, {
    method: 'GET',
  });
}

export async function getpredicted() {
  return await request(`/aipredict/api/v1/predict/`, {
    method: 'GET',
  });
}

export const getUserResource = async (params: object) => {
  return await aomRequest('user-group-resources', {
    method: 'GET',
    params,
  })
}

export const getUser = async () => {
  return await iamRequest('users/current');
}
